﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using DAL;
using Utility;
namespace BUS
{
    public class Tbl_ImageSP_BUS
    {
        public static Tbl_ImageSP_Collection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            Tbl_ImageSP_DAL imageDAL = new Tbl_ImageSP_DAL();
            return imageDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Tbl_ImageSP_Collection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            Tbl_ImageSP_DAL imageDAL = new Tbl_ImageSP_DAL();
            return imageDAL.Get(cri.Criter, 0, 0, Tbl_ImageSP_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static Tbl_ImageSP_Collection GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_ImageSP_Columns.SanPham.ToString(), Condition.EQUAL, iD);
            Tbl_ImageSP_DAL imgspDAL = new Tbl_ImageSP_DAL();
            Tbl_ImageSP_Collection imgspCollection = imgspDAL.Get(cri.Criter, 0, 0, Tbl_ImageSP_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (imgspCollection.Count > 0)
                return imgspCollection;
            return null;
        }
        public static Tbl_ImageSP_Collection demhinh(int iD)
        {
            int total = 0;
            Tbl_ImageSP_DAL hinhDAL = new Tbl_ImageSP_DAL();
            Tbl_ImageSP_Collection hinhCollection = hinhDAL.Get("where " +
             Tbl_ImageSP_Columns.SanPham.ToString() + " = " + iD.ToString(),
             0, 0, Tbl_ImageSP_Columns.STT.ToString(), "DESC", out total);
            if (hinhCollection.Count > 0)
                return hinhCollection;
             return null;
            
         }

        
        public static void Insert(Tbl_ImageSP_Entities image)
        {
            Tbl_ImageSP_DAL imageDAL = new Tbl_ImageSP_DAL();
            imageDAL.insert(image);
        }
        public static void Update(Tbl_ImageSP_Entities image)
        {
            Tbl_ImageSP_DAL imageDAL = new Tbl_ImageSP_DAL();
            imageDAL.Update(image);
        }
        public static void Delete(string tenHinh)
        {
            Tbl_ImageSP_DAL imageDAL = new Tbl_ImageSP_DAL();
            imageDAL.Delete(tenHinh);
        }
    }
}
